Refactor and not to use compile outside of lib
Strip trailing whitespace