Fixed a few bugs, and also fixed an error when building for the first time