Bug fixes and fmt