added const to some places
removed all registers
added constness