Basic functionality almost restored, with better code.