Cleaned up code and updated license headers