fixed some issues with references