Removed the hooks and replaced with inline logic, as per suggested.