Home refactoring and several bugs fixed.