Fix formatting issues, mkdir permissions, and unnecessary while loop around waitpid