Bugs

Fixes #278, #277, #281, and #282
Also cleans up some code using the power and beauty of idiomatic coffeescript.