Refactor dead code & fix