Fixed issues pointed in comments