Encapsulated code, added exception handling, improved documentation