Cleaned up code and updated version