added checking for class bound functions
Fixed several bugs and added more error checking