Refactor code for new system.