Compact finished

Pending to fix minor bugs.
Logic already done