Massive restructuring. Also added speclj tests.