Added action and fixed a few bugs