Got rid of some bugs from earlier code. Should work fine.