Added argument checking and defaults.