code restructuring

almost ready to finally put mysql in use