Removed some duplicate code.