Bug fix

A LOT of bugs fixed!