PARTIAL: Added integration tests & corrected underlying flaws.