lots of improvements bug fixes