Changes made by Kelvin Kosbab (kelvin@kosbab.com Various bug fixes.