Cleanup of code, bug fixes and testing non-primitive datatypes