Cleaning up error logging and fixing namespace bug