Fixed some build errors and warnings in master