Merged some of the changes proposed by Alexander