Code developed during my masters at UnB