Slightly improved error handling & object passing.