A bunch of fixes. Most of #1 is fixed