Cleanup qobj

WIP: Qobj cleanups, optimization and improvements.