More extensive rewriting... almost to something useable