Major bug fixes/format correction