Core/Phases: more work on corpse phasing
- moved all sql queries to prepared statements
- implemented corpse phases saving, loading, cleaning