Adding some logic for testing, fixing a few things