a lot of changes, not jet tested