Bug fixes, formatting