fixed overflow and positioning bugs