Cleaned up all code, fixed event emitters