Tidied code, wrapped in proper wrapper.