Has correct memory limit added. Some refactoring of code to make it look standardized.