Cleaned up code, added documentation