fix trailing spaces, and refactor obj creation