Started work on better particle code; unfinished!