ENH: Major refactor, add scripts, with same result as before