Minor changes, fixed a few functions