cleanups, proper trimming