Tidied up

Improved documentation, removed library call in function (not good practice), cleaned up messy code