Refactored register access and added some documentation