added init() and fixed bug with clearRegister()