Initial commit. Working fairly fine, but still contains some magic :).