Minor bug fixes and code improvements added.