Updated with some bug fixes.