Fixes for multiple issues

Fixes #174, #172, #162, #159, #146, #145, #90