improved code style and docblocks