Fixed several small bugs that were suggested by NeOn_sp on the forum.