Final version, cleaned up and ready to be used.