Fixes #2. Additional code cleanup.