Too many changes to mention, see diff for details