many many bug fixes for saved and delete, code refactor