Almost done; fixing style and bugs