makeing it all closure compilable. also cleaning up a little