Added documentation, remove unnecessary code