Made methods generic to greatly reduce required code.