Some cleanup and small bugfixing

Fixed a bug with using str().lstrip in a wrong way.
Did some minor cleanup