Numerous bug fixes, updated tests and coffeescript