Borrowed some things from Gary Bernhardt.