Some more code... needs testing.