Initial working code.