Update lib, format and clean up source