Fixed some warnings and cleaned some code