Remove debug prints, reorder, fix attr/index access