Cleaned up python functionality