Massive refactor and implementation of thin python frontend