Fix for webflis, some refactoring