some cleanup and new code

which needs to be finished later