Cleaned up the code and fixed functionality with operators.