fixed up option handling a bit.
merged and updated to compile with current rustc.