Code cleanup, added docs. closes #2