refactor
various fixes