Numerous bug fixes, updated tests and coffeescript

This pull request contains updated CoffeeScript files so lib can be rebuilt from src.