Minor changes, added some extra functionality.