refactored ak-db an ak-code; WIP