Cleaned code (warnings etc)

Fixes #1098 #1099 #1108
Why get rid of this? I'm not saying it's wrong, I just don't know why it's happening.