Moving Gonzalo's changes into master

I haven't fully tested these but since no one is yet actively using this I think it's high time these changes were moved into master