Some changes for multi-gpu implementation (not tested)