Some refactoring; removing redundant code.