Fixed issues pointed out by adamv