Refactored some of the monitor code