Added proper scope checking for object declarations and construction