some refactoring + spotx fixes