Code cleanup, squashed a few bugs and fixed readme.