Updated sqlite db structure and fixed some macro usage