Bug fixes, also fixed output