many small fixes
small fixes and some logic for register