afanasy: libafsql: code refactoring