Fixed code style and documented all the things!