improved option handling; code clean up