Fixed several issues
Implemented #39