Switched shell scripts to use sh, fixed some CMake bugs and added build types.