Cleaned, commented, added a few helper classes