Bug fixes and file cleanup