Major refactor, better structure and fixes for FF