Many small bug fixes
Merged conflict