Migrate JS to Coffee and re-org a bit