Various bug fixes, fixed bugs #5-7, can't really remember :P