Fixed a few bugs, added subfolder logic