Various fixes and important improvements