Threads and main separation (+new heartbeat thread)