Waypoints fix

Waypoints are loaded from database and changes are written back into
database.

Function to get next AUTO_INCREMENT of a database table added