Code cleanup. Setting up references