Improved database structure and querys