I tried getting the pieces to snap in a grid, but I couldn't figure out the math for the positioning. I might figure it out later though! Also, yeah it needs some bug fixes, like the ones you mentioned. Thanks for commenting!
I don't know which language and engine you are using, but for a 32 grid size wouldn't it be x=32*round(x/32) and y=32*round(y/32). Or you can use floor() instead of round() to always round up below. That's what I usually do