Basically port uppslink to Python and bug fixes