Ported edvardm from OMZ with a few tweaks