Fix #61

Also made some code styling improvements