Machine Codes

Pulled out machine codes to defines in headers as a refactor and started
to reduce and pull out common logic into functions.