Fix element bounds and other fixes