moved stuff over from gist and organised it