Major refactor, moving code out of monolithic hipchat2 file.