fixes and new register write routine