Added actions and fixed some problematic code