Fixes according to dagon666 comments