Bugfixing and warning clean ups