Cleaned up some garbage code and fixed a bug in errorCal