lots of changes just before I murder everything an reimpliment the master in python