Tidied things up a bit for new code implementations.