Improved performance for page loading, removed dirty code and started documenting