Closed #112
Fixed various bugs