Converted retrival.c to python. Slight refactor... some parts might be a bit hackish