Added base code, needs testing.