build.sh: Fixed some path issues, added some documentation, cleanup of function names