Bug fixes to make everything fit together