fixes some issues 

fixes #573, fixes #559