Fixing problems @purcell pointed out.
Thanks!