simplified most functions by using dynamic register pointers