added some formatting
fixed a few bugs