NUmerous fixes