minor fixes and add demo database construction code