Some code cleanup. Also get rid of compile warnings