Some refinements
Removed dead code