Massive code cleanup

Change-Id: I8c04d833169690c771549b87d2a411f487ad54a5