Code cleanup. Removed unused code, made naming clearer