Fixed glitches, added error handling