bug fix #4 many small changes