Removing duplicate and dead code