before changing to mysql
complete module but dirty and not tested
complete module, untested, modified layout