plenty of changes, ask me for details :D
this commit contains bugs!