library cleanup and code formatting