Boilerplate code originally taken from https://github.com/headchant/love-boilerplate with a few additions.