Bugfix and more updates

Add more primary keys, fix bug in daylight table insert, and general
fixes.