Many, many fixes and additions