work in progress, bugfix and cleaning