Switched reg orders properly, minor code optimization