Fixed errors and warnings

fixed several errors and warnings, and removed unused objects (dead
object removal)