Minor imrovements and bug fixes