added copy optimization ; type check; and code cleanup
added copy optimization ; type check; and code cleanup

travisturner/pilosa,raskle/pilosa,raskle/pilosa,linhvo/pilosa,linhvo/pilosa,linhvo/pilosa,raskle/pilosa