Added test code. Crashes at the end for some reason.