Self-updating feature, indentation fix, and SQL cleanup

Please don't close any issues apart from #87 based on this PR, there are more to PRs to come.
In fact, I think #87 should be closed.