Cleaned up source code
Closed #107
Fixed many minor bugs